﻿#region Using Directives

using System;

using Microsoft.SharePoint;

#endregion Using Directives

namespace StooRob.SharePoint.ContentUpdater
{
    /// <summary>
    /// Import WebPart exception class.
    /// </summary>
    public class ImportWebPartExcepton : StooRobException
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initialises a new instance of the <see cref="T:StooRob.SharePoint.ContentUpdater.ImportWebPartExcepton"/> class.
        /// </summary>
        /// <param name="webPartNamespace">The namespace of the WebPart that failed the import.</param>
        /// <param name="webPartZoneTitle">Title of the zone the WebPart was being added to.</param>
        /// <param name="webPartZoneTitle">Title of the WebPart that failed to be added.</param>
        /// <param name="webPartZoneIndex">Position in the zone the WebPart was being added to.</param>
        /// <param name="importError">Import error message.</param>
        public ImportWebPartExcepton(string webPartNamespace, string webPartZoneTitle, string webPartTitle, int webPartZoneIndex, string importError)
            : base()
        {
            string s = Exceptions.ImportWebPart;
            string error = string.IsNullOrEmpty(importError) ? "The import of the WebPart failed." : importError;

            if (!string.IsNullOrEmpty(webPartNamespace))
                _msg = string.Format(s, webPartNamespace, webPartZoneTitle, webPartZoneIndex < 0 ? "0" : webPartZoneIndex.ToString(), webPartTitle, error);
            else
                _msg = string.Format(s, webPartZoneTitle, webPartZoneIndex < 0 ? "0" : webPartZoneIndex.ToString(), webPartTitle, error);
        }

        #endregion Constructors and Destructors

    }
}